package com.dimong.www.loan.ui.frag;

import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dimong.www.loan.R;
import com.dimong.www.loan.bean.CmsBean;
import com.dimong.www.loan.ui.base.BaseTitleFragment;
import com.dimong.www.loan.widget.ActionBarView;

/**
 * Created by wuligang on 2018/5/29.
 */

public class CmsContentFrag extends BaseTitleFragment {
    private TextView tv_frag_cms_content;

    public CmsContentFrag() {

    }

    @Override
    public RelativeLayout getContainView() {
        return null;
    }

    @Override
    public void beforeInitView() {

    }

    @Override
    public void initView() {
        super.initView();
        tv_frag_cms_content = (TextView) findViewById(R.id.tv_frag_cms_content);
    }

    @Override
    public void setViewStatus() {
        if (getArguments() == null) {
            getActivity().finish();
            return;
        }
        CmsBean cmsBean = (CmsBean) getArguments().getSerializable("cmsBean");
        if (cmsBean == null) {
            getActivity().finish();
            return;
        }
        if (mTitle != null) {
            mTitle.setTitle(cmsBean.getTitle());
            mTitle.setLeftImg(new ActionBarView.OnLeftImgClickListener() {
                @Override
                public void onClick(View img) {
                    getActivity().finish();
                }
            });
        }

        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < cmsBean.getContent().size(); i++) {
            stringBuffer.append(cmsBean.getContent().get(i));
            stringBuffer.append("\n");
        }
        tv_frag_cms_content.setText(stringBuffer);
    }

    @Override
    public int getViewResourceId() {
        return R.layout.frag_cms_content;
    }
}
